package com.apes.scm.masterdata.car.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.fileserver.File;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：汽车厂牌
 *
 * @Auther: linwz
 * @Date: 2018/7/19 15:19
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CarLabel.CONST_TABLE_NAME)
public class CarLabel extends Model {

    public static final String CONST_TABLE_NAME = "mas_car_label";

    @Id
    @Column(name = "id", length = 6)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "厂牌编码",padding = 6)
    @Comment("厂牌编码")
    private String id;//厂牌编码

    @Column(name = "name",length = 120, nullable = false)
    @Comment("厂牌名称")
    private String name;//厂牌名称

    @Column(name = "car_brand",length = 60,nullable = false)
    @Comment("汽车品牌")
    private String carBrand;//汽车品牌

    @Column(name = "manufacturers",length = 60,nullable = false)
    @Comment("厂商")
    private String manufacturers ;//厂商

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "car_category", referencedColumnName = "id")
    @Comment("类别")
    private Enumeration carCategory;//类别(carCategory)(0:国产;1：进口;2：合资)

    @File
    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "LOGO",columnDefinition = "CLOB")
    @Comment("LOGO")
    private String logo;//对应的LOGOid

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "mas_car_brand_id", referencedColumnName = "id")
    @Comment("汽车品牌")
    private MasCarBrand masCarBrand;

}
